<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <el-form>
          <div class="box">
            <!--<div class="box_content">
              <el-input placeholder="请输入课程号" style="width: 200px"></el-input>
            </div>-->
            <div class="box_content">
              <el-select v-model="LessName" placeholder="请选择课程名称" value="">
                <el-option v-for="item in queryLession" :label="item.lession_name" :value="item.lession_name"></el-option>
              </el-select>
            </div>
            <div class="box_content">
              <el-select v-model="LessSem" placeholder="请选择学期">
                <el-option v-for="item in querySemester" :label="item.semester_name" :value="item.unid"></el-option>
              </el-select>
            </div>
            <div class="box_content">
              <el-select v-model="LessGrade" placeholder="请选择年级" value="">
                <el-option v-for="item in 16" :label="item+'年级'" :value="item"></el-option>
              </el-select>
            </div>
            <div class="box_content" style="text-align: right">
              <el-button type="primary" @click="queryScreenPayLession">查询</el-button>
              <el-button @click="restLess">重置</el-button>
            </div>
          </div>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-tabs v-model="activeName" @tab-click="tabhandleClick">
          <el-tab-pane label="全部课程" name="first">
            <el-button type="primary" @click="addClick" style="margin-bottom: 15px">新增收费项</el-button>
            <el-dialog v-loading="loading" title="新增收费项" :visible.sync="NewPay" width="750px">
              <el-form :model="LessionData" ref="LessionData" :rules="rules" label-width="90px">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="课程名称:" prop="unid">
                      <el-select v-model="LessionData.unid" placeholder="请选择" @change="queryLessionById('LessionData')">
                        <el-option v-for="item in queryLession" :label="item.lession_name" :value="item.unid"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="选用教材:">
                      <el-input v-model="LessionData.textbook_id" disabled></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="课程类型:">
                      <el-input v-model="LessionData.lession_type" disabled></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="课时:">
                      <el-input v-model="addPayLessionData.lession_time"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <el-form :model="addPayLessionData" ref="addPayLessionData" :rules="rules2" label-width="80px">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="任课老师:">
                      <el-input v-model="LessionData.teacher_name" disabled></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="学期:" prop="semester_id">
                      <el-select v-model="addPayLessionData.semester_id" placeholder="请选择">
                        <el-option v-for="item in querySemester" :label="item.semester_name" :value="item.unid"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="计费方式:" prop="pay_mode" label-width="90px">
                      <el-select v-model="addPayLessionData.pay_mode" placeholder="请选择">
                        <el-option label="按次收费" value="1"></el-option>
                        <el-option label="按小时收费" value="2"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-col :span="8" style="line-height: 40px;text-align: right;">
                      <el-form-item>
                        <el-checkbox v-model="addPayLessionData.is_period" true-label="1" false-label="0" style="font-weight: bold;" @change="anqi">按期收费</el-checkbox>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item>
                        <el-input style="margin-left: 10px" v-model="addPayLessionData.period" :disabled="per"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <div style="margin-left: 20px;line-height: 40px;font-weight: bold">
                        小时/次/期
                      </div>
                    </el-col>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="单价:" prop="price">
                      <el-input v-model="addPayLessionData.price"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="计费方式:" prop="pay_time" label-width="90px">
                      <el-select v-model="addPayLessionData.pay_time" placeholder="请选择" @change="inTime">
                        <el-option label="不限制" value="1"></el-option>
                        <el-option label="截止" value="2"></el-option>
                        <el-option label="X月内" value="3"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="16">
                    <el-col :span="12">
                      <el-form-item label="自购买之日起:" label-width="110px">
                        <el-select v-model="addPayLessionData.month" placeholder="请选择" :disabled="disabl">
                          <el-option v-for="item in 12" :label="item+'月内'" :value="item"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="截止:" label-width="80px">
                        <el-date-picker placeholder="选择时间" v-model="addPayLessionData.end_time" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" :disabled="disabl"></el-date-picker>
                      </el-form-item>
                    </el-col>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <div>
                      <el-radio-group v-model="addPayLessionData.class_mode" @change="changeHandler">
                        <div style="float: left">
                          <el-form-item label="班型设置:">
                            <el-radio label="1" value="1">满班</el-radio>
                            <el-radio label="2" value="2">小班</el-radio>
                          </el-form-item>
                        </div>
                        <div style="float: left;margin-left: 10px">
                          <el-input style="width: 100px" v-model="addPayLessionData.small_class" :disabled="smallClass"></el-input>
                        </div>
                        <div style="float: left;margin-left: 10px;line-height: 40px">
                          数字<el-radio label="3" value="3" style="margin-left: 10px">一对一</el-radio>
                        </div>
                      </el-radio-group>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="班型设置:">
                      <el-radio-group v-model="addPayLessionData.status">
                        <el-radio label="1">启用</el-radio>
                        <el-radio label="2">停用</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <div style="font-weight: bold">绑定物品:</div>
                    <el-table :data="tableData2" border style="width: 100%">
                      <el-table-column fixed prop="id" label="日期" :show-overflow-tooltip="true"></el-table-column>
                      <el-table-column prop="name" label="price" :show-overflow-tooltip="true"></el-table-column>
                      <el-table-column prop="danwei" label="省份" :show-overflow-tooltip="true"></el-table-column>
                      <el-table-column fixed="right" label="操作" :show-overflow-tooltip="true">
                        <template slot-scope="scope">
                          <el-button @click="handleClick(scope.row)" type="primary" size="small">查看</el-button>
                          <el-button type="warning" size="small">编辑</el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <div style="font-weight: bold">授权校区:</div>
                    <el-table :data="tableData2" border style="width: 100%">
                      <el-table-column fixed prop="id" label="日期" :show-overflow-tooltip="true"></el-table-column>
                      <el-table-column prop="name" label="price" :show-overflow-tooltip="true"></el-table-column>
                      <el-table-column prop="danwei" label="省份" :show-overflow-tooltip="true"></el-table-column>
                      <el-table-column fixed="right" label="操作" :show-overflow-tooltip="true">
                        <template slot-scope="scope">
                          <el-button @click="handleClick(scope.row)" type="primary" size="small">查看</el-button>
                          <el-button type="warning" size="small">编辑</el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-button type="primary" style="margin-left: 80px;">+添加</el-button>
                  </el-col>
                  <el-col :span="24" style="text-align: right;">
                    <div style="margin-right: 50px">
                      <el-button type="primary" @click="addPayLession('addPayLessionData')">提交</el-button>
                      <el-button>取消</el-button>
                    </div>
                  </el-col>
                </el-row>
              </el-form>
            </el-dialog>
            <el-table v-loading="loading" :data="queryData" border @selection-change="handleSelectionChange" style="width: 100%">
              <el-table-column type="selection" width="50px"></el-table-column>
              <el-table-column prop="lession.lession_name" label="课程名称" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column label="课程类型" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.lession.lession_type==1" type="success">线上</el-tag>
                  <el-tag v-if="scope.row.lession.lession_type==2" type="info">线下</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="semester.semester_name" label="学期" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column label="课程状态" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.status==1" type="success">启用</el-tag>
                  <el-tag v-if="scope.row.status==2" type="danger">停用</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="pay_mode" label="计费方式" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.pay_mode==1" type="success">按次收费</el-tag>
                  <el-tag v-if="scope.row.pay_mode==2" type="info">按小时收费</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="price" label="课程单价" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="pay_time" label="收费有效期" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.pay_time==1" type="success">不限制</el-tag>
                  <el-tag v-if="scope.row.pay_time==2" type="info">截止</el-tag>
                  <el-tag v-if="scope.row.pay_time==3" type="info">X月内</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="null" label="绑定项目" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="null" label="授权校区" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column fixed="right" label="操作" width="145">
                <template slot-scope="scope">
                  <el-button @click="handleClick(scope.row)" type="primary" size="small">查看</el-button>
                  <el-button type="warning" size="small" @click="stop(scope.$index, scope.row)">停用</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="block">
              <span class="demonstration"></span>
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="未定价课程" name="second">未定价课程</el-tab-pane>
          <el-tab-pane label="停用课程" name="third">
            <el-table :data="queryStop" border @selection-change="handleSelectionChange" style="width: 100%">
              <el-table-column type="selection" width="50px"></el-table-column>
              <el-table-column fixed prop="unid" label="unid" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="lession.lession_name" label="课程名称" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column label="课程类型" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.is_period==1" type="success">线上</el-tag>
                  <el-tag v-if="scope.row.is_period==2" type="info">线下</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="semester.semester_name" label="学期" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column label="课程状态" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.status==1" type="success">启用</el-tag>
                  <el-tag v-if="scope.row.status==2" type="danger">停用</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="pay_mode" label="计费方式" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.pay_mode==1" type="success">按次收费</el-tag>
                  <el-tag v-if="scope.row.pay_mode==2" type="info">按小时收费</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="price" label="课程单价" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="pay_time" label="收费有效期" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.pay_time==1" type="success">不限制</el-tag>
                  <el-tag v-if="scope.row.pay_time==2" type="info">截止</el-tag>
                  <el-tag v-if="scope.row.pay_time==3" type="info">X月内</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="null" label="绑定项目" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="null" label="授权校区" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column fixed="right" label="操作" width="145">
                <template slot-scope="scope">
                  <el-button @click="handleClick2(scope.row)" type="primary" size="small">查看</el-button>
                  <el-button type="warning" size="small">停用</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="block">
              <span class="demonstration"></span>
              <el-pagination
                @size-change="handleSizeChangeStop"
                @current-change="handleCurrentChangeStop"
                :current-page="currentPage"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total2">
              </el-pagination>
            </div>
          </el-tab-pane>
        </el-tabs>
        <el-dialog v-loading="loading" title="查看收费项" :visible.sync="queryDig" width="750px">
          <el-form label-width="80px">
            <el-row>
              <el-col :span="12">
                <el-form-item label="课程名称:">
                  <el-select v-model="querySelById.lession_name" disabled>
                    <el-option v-for="item in queryLession" :label="item.lession_name" :value="item.unid"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="选用教材:">
                  <el-input v-model="querySelById.lession_name" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="课程类型:">
                  <el-select :value="querySelById.lession_type" disabled>
                    <el-option label="线上" :value="1"></el-option>
                    <el-option label="线下" :value="2"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="课时:">
                  <el-input v-model="querySel.lession_time" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="任课老师:">
                  <el-input v-model="querySelById.teacher_name" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="学期:">
                  <el-select v-model="querySel.semester_id" placeholder="请选择" disabled>
                    <el-option v-for="item in querySemester" :label="item.semester_name" :value="item.unid" disabled></el-option>\
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="计费方式:">
                  <el-select v-model="querySel.pay_mode" placeholder="请选择" disabled>
                    <el-option label="按次收费" :value="1"></el-option>
                    <el-option label="按小时收费" :value="2"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-col :span="8" style="line-height: 40px;text-align: right;font-weight: bold">
                  按期收费
                </el-col>
                <el-col :span="8">
                  <el-input style="margin-left: 10px" v-model="querySel.period" disabled></el-input>
                </el-col>
                <el-col :span="8">
                  <div style="margin-left: 20px;line-height: 40px;font-weight: bold">
                    小时/次/期
                  </div>
                </el-col>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="单价:">
                  <el-input v-model="querySel.price" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="计费方式:">
                  <el-select :value="querySel.pay_time" disabled>
                    <el-option label="不限制" :value="1"></el-option>
                    <el-option label="截止" :value="2"></el-option>
                    <el-option label="X月内" :value="3"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-col :span="12">
                  <el-form-item label="自购买之日起:" label-width="110px">
                    <el-select v-model="querySel.month" placeholder="请选择" disabled>
                      <el-option v-for="item in 12" :label="item+'月内'" :value="item"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="截止:" label-width="80px">
                    <el-date-picker placeholder="选择时间" v-model="querySel.end_time" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" disabled></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <div>
                  <el-radio-group v-model="querySel.class_mode" @change="changeHandler" disabled>
                    <div style="float: left">
                      <el-form-item label="班型设置:">
                        <el-radio :label="1" value="1">满班</el-radio>
                        <el-radio :label="2" value="2">小班</el-radio>
                      </el-form-item>
                    </div>
                    <div style="float: left;margin-left: 10px">
                      <el-input style="width: 100px" v-model="querySel.small_class" disabled></el-input>
                    </div>
                    <div style="float: left;margin-left: 10px;line-height: 40px">
                      数字<el-radio :label="3" value="3" style="margin-left: 10px">一对一</el-radio>
                    </div>
                  </el-radio-group>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="班型设置:">
                  <el-radio-group v-model="querySel.status" disabled>
                    <el-radio :label="1">启用</el-radio>
                    <el-radio :label="2">停用</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <div style="font-weight: bold">绑定物品:</div>
                <el-table :data="tableData2" border style="width: 100%">
                  <el-table-column fixed prop="id" label="日期" :show-overflow-tooltip="true"></el-table-column>
                  <el-table-column prop="name" label="price" :show-overflow-tooltip="true"></el-table-column>
                  <el-table-column prop="danwei" label="省份" :show-overflow-tooltip="true"></el-table-column>
                  <el-table-column fixed="right" label="操作" :show-overflow-tooltip="true">
                    <template slot-scope="scope">
                      <el-button @click="handleClick(scope.row)" type="primary" size="small">查看</el-button>
                      <el-button type="warning" size="small">编辑</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <div style="font-weight: bold">授权校区:</div>
                <el-table :data="tableData2" border style="width: 100%">
                  <el-table-column fixed prop="id" label="日期" :show-overflow-tooltip="true"></el-table-column>
                  <el-table-column prop="name" label="price" :show-overflow-tooltip="true"></el-table-column>
                  <el-table-column prop="danwei" label="省份" :show-overflow-tooltip="true"></el-table-column>
                  <el-table-column fixed="right" label="操作" :show-overflow-tooltip="true">
                    <template slot-scope="scope">
                      <el-button @click="handleClick(scope.row)" type="primary" size="small">查看</el-button>
                      <el-button type="warning" size="small">编辑</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-button type="primary" style="margin-left: 80px;">+添加</el-button>
              </el-col>
              <el-col :span="24" style="text-align: right;">
                <div style="margin-right: 50px">
                  <el-button type="primary" @click="addPayLession">提交</el-button>
                  <el-button>取消</el-button>
                </div>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import { queryPayLession,selectPayLession,querySemesterList,queryLessionList,queryLessionById,addPayLession,queryTeachById,getPayItem } from '@/api/studentRecruit.js'
  import { getSessionInfo, delSessionInfo } from '@/utils/auth'
  import store from '../../store'
  export default {
    name: 'index',
    data() {
      return {
        LessGrade:null,
        LessSem:null,
        LessName:null,
        loading:false,
        page: 1,
        limit: 10,
        total: 0,
        total2: 0,
        currentPage: 1,
        smallClass:true,
        disabl:false,
        per:true,
        queryDig:false,
        querySel:{},
        querySelById:{},
        queryLess:{},
        queryStop:[],
        addPayLessionData:{
          lession_id:null,
          lession_time:null,
          semester_id:null,
          pay_mode:null,
          is_period:0,
          period:null,
          price:null,
          pay_time:null,
          end_time:null,
          month:null,
          class_mode:null,
          small_class:null,
          status:null,
        },
        LessionData:{
          unid:null,
          lession_name:null,
          lession_type:null,
          textbook_id:null,
          lession_time:null,
          is_custom:null,
          grade:null,
          teacher_id:null,
          teacher_name:null,
          lession_desc:null,
          lession_photo:null,
          lession_num:null,
          is_free:null,
        },
        querySemester:null,
        queryLession:null,
        queryData:null,
        queryData2:null,
        checked: false,
        NewPay: false,
        activeName: 'first',
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }],
        tableData2:[{
          id:1,
          name:'哈哈',
          danwei:'前端'
        }],
        rules: {
          unid: [
            { required: true, message: '请选择课程', trigger: 'blur,change' }
          ]
        },
        rules2: {
          semester_id: [
            { required: true, message: '请输入姓名', trigger: 'blur,change' }
          ],
          pay_mode: [
            { required: true, message: '请输入性别', trigger: 'blur,change' }
          ],
          lession_type: [
            { required: true, message: '请输入性别', trigger: 'blur,change' }
          ],
          price: [
            { required: true, message: '请输入性别', trigger: 'blur,change' }
          ],
          pay_time: [
            { required: true, message: '请输入性别', trigger: 'blur,change' }
          ]
        }
      }
    },
    methods: {
      //重置条件查询
      async restLess(){
        this.LessName = null
        this.LessGrade = null
        this.LessSem = null
        this.$message.success('重置成功！')
        this.queryPayLession()
      },
      //条件查询
      async queryScreenPayLession(){
        if(this.LessName == null && this.LessGrade == null && this.LessSem == null){
         this.$message.error('请输入要查询的条件！')
        }else {
          let queryData = {
            page:this.page,
            limit:this.limit,
            lession_name:this.LessName,
            grade:this.LessGrade,
            semester_id:this.LessSem
          }
          let resData = await queryPayLession(queryData)
          if(resData.code == 200){
            this.$message.success('查询成功！')
            this.queryData = resData.data.list
          }else {
            this.$message.error('查询失败！')
          }
        }
      },
      //停用
      async stop(index,row){
        console.log(row)
        let stopData = {
          unid:row.unid,
          status:2
        }
        let resData = await addPayLession(stopData)
        if(resData.code == 200){
          this.$message.success('停用成功!')
          this.queryPayLession()
          console.log('resData',resData)
        }else {
          this.$message.error('停用失败!')
        }
      },
      /*每页几条*/
      handleSizeChange(val) {
        this.limit = val
        this.queryPayLession()
        console.log(`每页 ${val} 条`)
      },
      /*当前页*/
      handleCurrentChange(val) {
        this.page = val
        this.queryPayLession()
        console.log(`当前页: ${val}`)
      },
      /*每页几条*/
      handleSizeChangeStop(val) {
        this.limit = val
        this.queryPayStopLession()
        console.log(`每页 ${val} 条`)
      },
      /*当前页*/
      handleCurrentChangeStop(val) {
        this.page = val
        this.queryPayStopLession()
        console.log(`当前页: ${val}`)
      },
      anqi(val){
        if (val==0){
          this.addPayLessionData.period = null
          this.per = true
        }else {
          this.per = false
        }
      },
      changeHandler(event){
        if (event==2){
          this.smallClass = false
        }else {
          this.addPayLessionData.small_class = null
          this.smallClass = true
        }
      },
      inTime(event){
        if (event!=3){
          this.addPayLessionData.end_time = null
          this.addPayLessionData.month = null
          this.disabl = true
        }else {
          this.disabl = false
        }
      },
      tabhandleClick(){

      },
      //根据unid查看数据
      async handleClick(tab, event) {
        this.loading = true
        this.queryDig = true
        this.querySel = tab
        console.log('点击查看时获取课程id',this.querySel)
        let queryData = {
          unid:tab.lession_id
        }
        let querySelById = await queryLessionById(queryData)
        this.querySelById = querySelById.data
        if (querySelById.code == 200){
          console.log('根据课程id查询：',querySelById.data)
          this.loading = false
        }
        let queryLessData = {
          unid:this.querySelById.textbook_id
        }
        let queryLess = await queryTeachById(queryLessData)
        if(queryLess.code == 200){
          this.queryLess = queryLess.data
          this.loading = false
        }
      },
      async handleClick2(tab, event) {
        this.queryDig = true
        this.querySel = tab
        let queryData = {
          unid:tab.lession_id
        }
        let querySelById = await queryLessionById(queryData)
        this.querySelById = querySelById.data
        let queryLessData = {
          unid:this.querySelById.textbook_id
        }
        let queryLess = await queryTeachById(queryLessData)
        this.queryLess = queryLess.data
      },
      /*表格全选方法*/
      handleSelectionChange(val) {
        /*this.multipleSelection = val;*/
        console.log('22222222222222222')
        console.log(val)
        console.log('22222222222222222')
      },
      //分页查询全部课程
      async queryPayLession(){
        this.loading = true
        let queryData = {
          page:this.page,
          limit:this.limit
        }
        let resData = await queryPayLession(queryData)
        if(resData.code == 200){
          console.log('分页查询全部课程',resData.data.list)
          this.loading = false
        }
        this.total = resData.data.total
        this.queryData = resData.data.list
      },
      //分页查询全部停用课程
      async queryPayStopLession(){
        this.loading = true
        let queryData = {
          page:this.page,
          limit:this.limit,
          status:2
        }
        let resData = await queryPayLession(queryData)
        if(resData.code == 200){
          console.log('分页查询全部停用课程',resData.data.list)
          this.loading = false
        }
        this.total2 = resData.data.total
        this.queryStop = resData.data.list
      },
      //获取学期信息
      async querySemesterList(){
        let queryData = {}
        let resData = await querySemesterList(queryData)
        this.querySemester = resData.data
        console.log('获取学期信息',resData.data)
      },
      //获取课程信息
      async queryLessionList(){
        let queryData = {}
        let resData = await queryLessionList(queryData)
        this.queryLession = resData.data
        console.log('获取课程信息',resData.data)
      },
      //根据unid查询课程
      queryLessionById(LessionData){
        this.$refs[LessionData].validate((valid) => {
          if (valid) {
            this.loading = true
            let queryData = {
              unid:this.LessionData.unid
            }
            queryLessionById(queryData).then(resData => {
              if(resData.code == 200){
                this.LessionData = resData.data
                console.log('根据unid查询课程',resData.data)
                this.addPayLessionData.lession_id = this.LessionData.unid
                this.loading = false
              }
            })
          }else {
            console.log(valid);
            return false;
          }
        });
      },
      async selectPayLession(){
        let queryData = {}
        let resData = await selectPayLession(queryData)
      },
      //添加课程
      addPayLession(addPayLessionData){
        this.$refs[addPayLessionData].validate((valid) => {
          if (valid) {
            this.loading = true
            addPayLession(this.addPayLessionData).then(resData => {
              console.log('添加课程',resData)
              if(resData.code == 200){
                this.$message.success("添加成功！")
                this.loading = false
                this.queryPayLession()
              }else {
                this.$message.error("添加失败！")
              }
            })
          }else {
            console.log(valid);
            return false;
          }
        });
      },
      //获取所有收费项目
      async getPayItem(){
        let queryData = {
          lession_id:null
        }
        let resData = await getPayItem(queryData)
        console.log('获取所有收费项目',resData)
      },
      addClick(){
        this.NewPay = true
      }
    },
    computed:{

    },
    created() {
      this.queryPayLession()
      this.querySemesterList()
      this.queryLessionList()
      this.getPayItem()
      this.queryPayStopLession()
      /*this.queryLessionById()*/
    },
  }
</script>

<style scoped>
  .box {
    width: 100%;
    display: flex;
    flex-direction: row;
    /*//两侧对齐*/
    justify-content: space-between;
    /*//自动换行*/
    flex-wrap: wrap;
    /*//清除上下行的中间空隙*/
    align-content: flex-start;
  }

  .box_content {
    flex: 30 200px;
  }

  /*//解决最后一行的问题*/
  .box:after {
    content: '';
    width: 30%;
  }
</style>
